package com.education.welco.service.impl;

import com.education.common.utils.Convert;
import com.education.welco.mapper.StudentWorkMapper;
import com.education.welco.pojo.StudentWork;
import com.education.welco.service.IStudentWorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 学生作业 服务层实现
 *
 * @author d
 * @date 2022-06-27
 */
@Service
public class StudentWorkServiceImpl implements IStudentWorkService {

    @Autowired
    private StudentWorkMapper studentWorkMapper;

    /**
     * 查询学生作业信息
     *
     * @param teaWorkId 学生作业ID
     * @param stuId 学生用户ID
     * @return 学生作业信息
     */
    @Override
    public StudentWork selectStudentWorkById(Integer teaWorkId,Integer stuId) {
        return studentWorkMapper.selectStudentWorkById(teaWorkId,stuId);
    }

    /**
     * 查询学生作业列表
     *
     * @param studentWork 学生作业信息
     * @return 学生作业集合
     */
    @Override
    public List<StudentWork> selectStudentWorkList(StudentWork studentWork) {
        return studentWorkMapper.selectStudentWorkList(studentWork);
    }

    /**
     * 新增学生作业
     *
     * @param studentWork 学生作业信息
     * @return 结果
     */
    @Override
    public int insertStudentWork(StudentWork studentWork) {
        return studentWorkMapper.insertStudentWork(studentWork);
    }

    /**
     * 修改学生作业
     *
     * @param studentWork 学生作业信息
     * @return 结果
     */
    @Override
    public int updateStudentWork(StudentWork studentWork) {
        return studentWorkMapper.updateStudentWork(studentWork);
    }

    /**
     * 删除学生作业对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteStudentWorkByIds(String ids) {
        return studentWorkMapper.deleteStudentWorkByIds(Convert.toStrArray(ids));
    }

    @Override
    public String selectTeaIdByTeaWorkId(String teaWorkId) {
        return studentWorkMapper.selectTeaIdByTeaWorkId(teaWorkId);
    }

    @Override
    public StudentWork selectStudentWorkByStuWorkId(Integer stuWorkId) {
        return studentWorkMapper.selectStudentWorkByStuWorkId(stuWorkId);
    }

    @Override
    public Integer countWorkAnswerNumByWorkId(Integer id) {
        return studentWorkMapper.countWorkAnswerNumByWorkId(id);
    }
}